//
//  MyCollectionViewCell.m
//  Boom
//
//  Created by 云鹏 赵 on 15/3/11.
//  Copyright (c) 2015年 lanou3g. All rights reserved.
//

#import "MyCollectionViewCell.h"

@implementation MyCollectionViewCell
- (void)dealloc
{
    [_allModel release];
    [_myImageView release];
    [_titleLable release];
    [_countsLable release];
    [super dealloc];
}
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self creatCells];
    }
    return self;
}
- (void)creatCells
{
    self.myImageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, 100, 100)];
    self.myImageView.backgroundColor = [UIColor whiteColor];
    [self addSubview:self.myImageView];
    [_myImageView release];
    
    self.titleLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 100, 30)];
    self.titleLable.backgroundColor = [UIColor whiteColor];
    self.titleLable.numberOfLines = 0;
    self.titleLable.font = [UIFont systemFontOfSize:13.0];
    self.titleLable.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.titleLable];
    [_titleLable release];
    
    self.countsLable = [[UILabel alloc] initWithFrame:CGRectMake(0, 130, 100, 20)];
    self.countsLable.backgroundColor = [UIColor whiteColor];
    self.countsLable.numberOfLines = 0;
    self.countsLable.font = [UIFont systemFontOfSize:10.0];
    self.countsLable.textColor = [UIColor grayColor];
    self.countsLable.textAlignment = NSTextAlignmentCenter;
    [self addSubview:self.countsLable];
    [_countsLable release];

}

- (void)setAllModel:(AllModel *)allModel
{
    if (_allModel != allModel) {
        [_allModel release];
        _allModel = [allModel retain];
    }
    // 下载图片 SD
    NSString *string = _allModel.albumCoverUrl290;
    NSURL *url = [NSURL URLWithString:string];
    [self.myImageView sd_setImageWithURL:url placeholderImage:nil];
    
//    NSString *string = _allModel.albumCoverUrl290;
//    NSURL *url = [NSURL URLWithString:string];
//    NSData *data = [NSData dataWithContentsOfURL:url];
//    UIImage *image = [UIImage imageWithData:data];
//    
//    self.myImageView.image = image;
    // titleLable
    self.titleLable.text = _allModel.title;
    // countsLable
    NSString *str = [NSString stringWithFormat:@"播放: %d", _allModel.playsCounts];
    self.countsLable.text = str;
}
@end
